package model.dao;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import model.vo.MemberVO;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;



public class MemberDAOImpl  extends SqlMapClientDaoSupport implements MemberDAO{
	//아이디 유무확인
	@Override
	public boolean findId(String logId) throws SQLException {
		boolean flag=false;
		String str=(String) super.getSqlMapClientTemplate().getSqlMapClient().queryForObject("member.findId", logId);
		if(str!=null){
			flag=true;
		}
		return flag;
	}
	//로그인
	@Override
	public MemberVO login(String logId, String logPw) throws SQLException {
		Map map=new HashMap();
		map.put("id", logId);
		map.put("password", logPw);
		return (MemberVO) super.getSqlMapClientTemplate().queryForObject("member.login",map);
	}
	//[환경설정]
	//멤버 리스트
	@Override
	public List memberList() throws SQLException {
		return super.getSqlMapClientTemplate().getSqlMapClient().queryForList("member.memberList");
	}
	// member logID  유효성 검사
	@Override
	public boolean searchMemberId(String logID) throws SQLException {
		boolean flag=false;
		String str=(String) super.getSqlMapClientTemplate().getSqlMapClient().queryForObject("member.searchMemberId", logID);
		if(str!=null){
			flag=true;
		}
		return flag;
	}
	//멤버  등록
	@Override
	public void member_insert(MemberVO vo) throws SQLException {
		super.getSqlMapClientTemplate().getSqlMapClient().insert("member.member_insert", vo);
	}
	//member 수정 페이지로 이동
	@Override
	public MemberVO member_updatePage(String logID) throws SQLException {
		return (MemberVO) super.getSqlMapClientTemplate().getSqlMapClient().queryForObject("member.member_updatePage", logID);
	}
	
	//member 수정
	@Override
	public void member_update(MemberVO vo) throws SQLException {
		super.getSqlMapClientTemplate().getSqlMapClient().update("member.member_update", vo);
	}
	
	//member 삭제
	@Override
	public void member_delete(String logID) throws SQLException {
		super.getSqlMapClientTemplate().getSqlMapClient().delete("member.member_delete", logID);
	}
	//비밀번호 변경
	@Override
	public void member_updatePassword(MemberVO vo) throws SQLException{
		super.getSqlMapClientTemplate().getSqlMapClient().update("member.member_updatePassword", vo);
	}
}
